#include "TIM.h"

void Timer1_Init(uint16_t freq)                                              
{
    /*(1)设置Timer1 的时钟*/
    TMR01_SEL_CLK(TMR_CLK_SEL_HSI);			      
	TMR_ConfigClk(TIMER1, TMR_CLK_DIV_1);		 
	SYS_EnablePeripheralClk(SYS_CLK_TIMER01_MSK); 
	/*(2)设置Timer1 运行模式*/	
	TMR_ConfigRunMode(TIMER1, TMR_COUNT_PERIOD_MODE, TMR_BIT_32_MODE);	
	TMR_DisableOneShotMode(TIMER1);										  
	/*(3)设置Timer1 运行周期*/		
	TMR_SetPeriod(TIMER1, TIMER1_CLK/freq);			
	/*(4)设置Timer1 中断*/	
	TMR_EnableOverflowInt(TIMER1);
    NVIC_SetPriority(TIMER1_IRQn, 2);	
	NVIC_EnableIRQ(TIMER1_IRQn);	
	/*(5)开启Timer1*/	
	TMR_Start(TIMER1);			
}
